@page "/pdf/barcode"
@inject Microsoft.JSInterop.IJSRuntime JS
@using System.IO
@using Syncfusion.Blazor.Buttons
@inject Microsoft.AspNetCore.Hosting.IWebHostEnvironment hostingEnvironment
@inherits SampleBaseComponent;
@*Hidden:Lines*@

@using BlazorDemos.Data.FileFormats.PDF

@*End:Hidden*@

<SampleDescription>
  <p>This sample demonstrates the creation of barcode in the PDF document and does not requires barcode font for creating barcode. It supports both 1D and 2D barcode with many customizing properties.</p>  
</SampleDescription>
<ActionDescription>
   <p>This feature can be used in invoice, super markets, health care systems and more. More information about the barcode can be found in this documentation <a target='_blank' href='https://help.syncfusion.com/file-formats/pdf/working-with-barcode'>section.</a></p>
</ActionDescription>

<div class="control-section">
    <p style="font-weight:normal">Click the button to view a PDF document generated by Essential PDF. Please note that Adobe Reader or its equivalent is required to view the resultant document. </p>

    <div class="button-section">
        <div id="button-control">
            <div class="row">
                <div>
                    <SfButton @onclick="GeneratePDF">Generate PDF</SfButton>
                </div>
            </div>
        </div>
    </div>
</div>

<style>
    .radio-control {
        margin: 0 0 5% 0;
    }

    .control-section .row {
        margin: 10px 0;
    }
</style>

@code {

     
    /// <summary>
    /// Create and download the simple PDF document
    ///<summary>
    protected async void GeneratePDF(MouseEventArgs args)
    {        
        BarcodeService service= new BarcodeService(hostingEnvironment);
        MemoryStream documentStream = service.CreateBarcode();
        await JS.SaveAs("Barcode.pdf", documentStream.ToArray());
    }
}
